package com.ruoyi.eqmonitor.service.impl;

import cn.hutool.json.JSONArray;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.eqmonitor.domain.BzDataEntity;
import com.ruoyi.eqmonitor.mapper.IBzDataMapper;
import com.ruoyi.eqmonitor.service.IBzDataService;
import org.springframework.stereotype.Service;

@Service
public class BzDataServiceImpl extends ServiceImpl<IBzDataMapper, BzDataEntity> implements IBzDataService {
    @Override
    public JSONArray getDataByIp(String ip) {
        BzDataEntity bzDataEntity = this.lambdaQuery().eq(BzDataEntity::getIp, ip).orderByDesc(BzDataEntity::getCreateTime).last("limit 1").one();
        if (bzDataEntity != null) {
            return bzDataEntity.getJsonData();
        }
        return null;
    }
}
